<?php
if (!isset($modoBusqueda)){
    $contextMenu[0]["link"]      = "javascript:fn_nuevo();";
    $contextMenu[0]["linkIcon"]  = "application_add.png";
    $contextMenu[0]["linkTitle"] = "Nueva Orden";
}?>

<script>
fn_nuevo = function ()
{		
    $("#zonaContenedor").load("/gourmet-express/trunk/src/index.php?do=MrpProOrd&accion=nuevo", function(){
    
    });
};

fn_guardar = function ()
{	
    var guardar = confirm("Desea guardar los datos?")
    if ( guardar ) 
    {
        var str=$("#form_nuevo").serialize();
        $.ajax({
                    url:'/gourmet-express/trunk/src/index.php?do=MrpProOrd&accion=guardarSave',
                    data:str,
                    type:'get',
                    dataType: "json",
                    success:function (data){                                           
                                                if(data.rpta=='true')
                        				        {
                        					        //listarOrdenesProduccion();
                                                                        fn_editar(data.ordenId);
                        				        }else{
                        				            alert(data.msg);
                        				        } 
                                            }
                });
    }
};
		
fn_editar = function (ordenId)
{
				
    $("#zonaContenedor").load("/gourmet-express/trunk/src/index.php?do=MrpProOrd&accion=editar&txtOrdenId="+ordenId, function(){
	});
};
			
fn_actualizar = function ()
{
	var actualizar = confirm("Desea actualizar los datos?")
	if ( actualizar ) {
	var str=$("#form_editar").serialize();
	$.ajax({
                url:'/gourmet-express/trunk/src/index.php?do=MrpProOrd&accion=editarSave',
                data:str,
                type:'get',
                dataType: "json",
                success:function (data){
                                            if(data.rpta=='true')
                    				        {
                    					        //listarOrdenesProduccion();
                                                                fn_editar(data.ordenId);
                    				        }else{
                    				            alert(data.msg);
                    				        }                                    
                	                    }
		   });
	}
 };	
	      	
fn_detalle = function (ordenId)
{
				
    $("#zonaContenedor").load("/gourmet-express/trunk/src/views/mrp/produccion/ordenes/detalle.php?txtOrdenId="+ordenId, function(){
    });				
};
			
fn_eliminar = function (pro_eli,tr_id){
      	
};




</script>

<body>
<div id="main">
  <?php include $_SERVER['DOCUMENT_ROOT'].'/gourmet-express/trunk/src/views/header.inc'; ?>
  <div id="zonaContenedor">
    <h3>.:: Ordenes de produccion </h3>
    <div>

		<form name="frm_buscaOrdenes" id="frm_buscaOrdenes">    
		    Orden Id : <input type="text" value="" size="15" name="txtOrdenId" id='txtOrdenId'>
		    Cliente Id : <input type="text" value="" size="25" name="txtClienteId" id='txtClienteId'>  
		    <input type="submit" value="aceptar" name="Buscar">   
		</form>   
		
		<table id="flex1" style="display:none"></table>
		<script type="text/javascript">
		$("#flex1").flexigrid({
			url: '/gourmet-express/trunk/src/index.php?do=MrpProOrd&accion=contenedor',
			dataType: 'json',
			colModel : [
				{display: 'Orden', name : 'ordenId', width : 80, sortable : true, align: 'left'},
				{display: 'Cliente', name : 'clienteId', width : 130, sortable : true, align: 'left'},
				{display: 'Producto', name : 'productoId', width : 130, sortable : true, align: 'left'},
				{display: 'Cantidad', name : 'cantProdc', width : 65, sortable : true, align: 'right'},
				//{display: 'Fec Produc Ini', name : 'fecProducIni', width : 75, sortable : true, align: 'left'},
				//{display: 'Fec Produc Fin', name : 'fecProducFin', width : 75, sortable : true, align: 'left'},
				{display: 'Fec Req', name : 'fecReq', width : 75, sortable : true, align: 'left'},
				// {display: 'Almacen', name : 'almacenId', width : 60, sortable : true, align: 'left'},
				{display: '&nbsp;', name : 'opciones', width : 80, sortable : true, align: 'right'}
				],
			searchitems : [
				{display: 'Receta Id', name : 'ordenId'},
				{display: 'Cliente', name : 'clienteId', isdefault: true}
				],
			sortname: "ordenId",
			sortorder: "desc",
			usepager: true,
			title: 'Ordenes',
			useRp: true,
			rp: 15,
			showTableToggleBtn: true,
			width: 800,
			onSubmit: addFormData,
			height: 300
		});   
		
		
		//This function adds paramaters to the post of flexigrid. You can add a verification as well by return to false if you don't want flexigrid to submit			
		function addFormData(){
			//passing a form object to serializeArray will get the valid data from all the objects, but, if the you pass a non-form object, you have to specify the input elements that the data will come from
			var dt = $('#frm_buscaOrdenes').serializeArray();
			$("#flex1").flexOptions({params: dt});
			return true;
		}
			
		$('#frm_buscaOrdenes').submit(function (){
			$('#flex1').flexOptions({newp: 1}).flexReload();
			return false;
		});
		</script>
	</div>
	<div id="div_listar" align="center"></div>
	<div id="div_oculto" style="display: none;"></div>
    </div>
</div>        
</body>
<script>
//fn_buscar();
</script>
